package pkg

import (
	"os"
	"time"
)

const (
	frameworkVersion = "v0.1.0"
	frameworkName    = "yggdrasil"
)

var (
	hostname  string
	startTime string

	buildTime  string
	buildTags  string
	goVersion  string
	gitHash    string
	appVersion string
	appName    string = frameworkName
	appID      string
)

func setHostname() {
	name, err := os.Hostname()
	if err != nil {
		name = "unknown"
	}
	hostname = name
}

func init() {
	setHostname()
	startTime = time.Now().Format("2006-01-02T15:04:05")
}

// HostName get host name
func Hostname() string {
	return hostname
}

//StartTime get start time
func StartTime() string {
	return startTime
}

//GoVersion get go version
func GoVersion() string {
	return goVersion
}

//BuildTime get build time
func BuildTime() string {
	return buildTime
}

//GitHash get git hash
func GitHash() string {
	return gitHash
}

//AppVersion get app version
func AppVersion() string {
	return appVersion
}

//AppName get app name
func AppName() string {
	return appName
}

//AppID get app name
func AppID() string {
	return appID
}

//BuildTags get build tags
func BuildTags() string {
	return buildTags
}

//FrameworkVersion get framework version
func FrameworkVersion() string {
	return frameworkVersion
}

//FrameworkName get framework version
func FrameworkName() string {
	return frameworkName
}

/**
go build -ldflags "-X 'gitee.com/zawei/yggdrasil.buildTime=`date "+%Y-%m-%d %H:%M:%S %z"`' \
-X 'gitee.com/zawei/yggdrasil.gitHash=`git log --pretty=format:"%H" -1`' \
-X 'gitee.com/zawei/yggdrasil.appVersion=`git describe --tags $(git rev-list --tags --max-count=1)`' \
-X 'gitee.com/zawei/yggdrasil.buildTags= 1 2 3' \
-X 'gitee.com/zawei/yggdrasil.goVersion=`go version | sed "s/go version //"`' "
*/
